// 图的dfs遍历
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;

const int N = 100010, M = N * 2;

int n, m;
int h[N], e[M], ne[M], idx; // 如果是无向边的话 就需要M = N * 2
bool st[N];
void add(int a, int b) {
    e[idx] = b, ne[idx] = h[a], h[a] = idx++;
}

void dfs(int u) {
    st[u] = true;

    for (int i = h[i]; i != -1; i = ne[i]) {
        int j = e[i];
        if (!st[j]) dfs(j);
    }
}

int main() {
    memset(h, -1, sizeof h);
    dfs(1);
    return 0;
}
